<template>
    <Card style="font-family:PMingLiU,Helvetica,sans-serif;font-size: 100%">
        <Row :gutter="16">
            <Col :span="span1">
                <div v-show="showBox">
                    <Card style="font-size: 18px" :bordered="false" :dis-hover="true">
                        <p slot="title" style="height: 33px">
                            <Row>
                                <Col style="font-size: 18px" span="24">
                                    <ButtonGroup>
                                        <Button type="ghost" icon="printer" @click="printMedical">打印病历</Button>
                                        <Button type="ghost" icon="printer" @click="printExecute">打印医嘱</Button>
                                        <Button type="ghost" icon="printer" @click="printCourse">打印病程记录</Button>
                                        <Button type="ghost" icon="power" @click="exit">关闭</Button>
                                    </ButtonGroup>
                                </Col>
                            </Row>
                        </p>
                        <Row>
                            <Col span="6">
                                <Row>
                                    <Col span="24">
                                        <!--<Avatar v-if="formItem.sex === 1" style="width: 100%;height: 150px" src="src/images/male.png" shape="square" />-->
                                        <!--<Avatar v-if="formItem.sex === 2" style="width: 100%;height: 150px" src="src/images/female.png" shape="square" />-->
                                        <img v-if="formItem.sex === 1" style="width: 100%;height: 150px;border: 1px solid #D5E4F1" src="@/images/male.png"/>
                                        <img v-if="formItem.sex === 2" style="width: 100%;height: 150px;border: 1px solid #D5E4F1" src="@/images/female.png"/>
                                    </Col>
                                </Row>
                                <Row>
                                    <Col span="24">
                                        <Tag align="center" style="width: 100%;font-size: 13px" color="blue">{{formItem.medicalNumber | valueFilter}}</Tag>
                                    </Col>
                                </Row>
                                <Row>
                                    <Col span="24">
                                        <Tag align="center" style="width: 100%;font-size: 13px" color="yellow">信用分：{{formItem.score}}</Tag>
                                    </Col>
                                </Row>
                            </Col>
                            <Col span="18">
                                <Carousel v-model="selectCarousel">
                                    <CarouselItem style="padding-right: 30px">
                                        <Row >
                                            <Col span="6" class="code-row-col-name">姓名</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.name}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">昵称</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.nickName | valueFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">性别</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.sex | sexFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">出生日期</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.birthday | valueFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">民族</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.ethnic | ethnicFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">婚姻状况</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.marital | maritalFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">文化程度</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.culture | cultureFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">患者来源</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.source | sourceFilter}}</Col>
                                        </Row>
                                    </CarouselItem>
                                    <CarouselItem style="padding-right: 30px">
                                        <Row >
                                            <Col span="6" class="code-row-col-name">职业</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.job | jobFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">身份证</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.card | valueFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">籍贯</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.origin | valueFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">工作特点</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.jobCharact | jobCharactFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">现住址</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.address | valueFilter}}</Col>
                                        </Row>
                                        <Row >
                                            <Col span="6" class="code-row-col-name">常驻地</Col>
                                            <Col span="18" class="code-row-col-value">{{formItem.resident | valueFilter}}</Col>
                                        </Row>
                                    </CarouselItem>
                                </Carousel>
                            </Col>
                        </Row>
                    </Card>
                    <Tabs :value="selectPane1" type="card" value="1" @on-click="clickTabs1">
                        <TabPane name="1" label="主诉现病史">
                            <complaint ref="complaint1" :recordType="1" v-on="{selectComplaint:selectComplaint}"></complaint>
                        </TabPane>
                        <TabPane name="2" label="既往史">
                            <complaint ref="complaint2" :recordType="2" v-on="{selectComplaint:selectComplaint}"></complaint>
                        </TabPane>
                        <TabPane name="3" label="家族史">
                            <family-history ref="familyHistory"></family-history>
                        </TabPane>
                        <TabPane name="4" label="个人史">
                            <personal-history ref="personalHistory"></personal-history>
                        </TabPane>
                        <TabPane name="5" label="特殊记录">
                            <special-records ref="specialRecords"></special-records>
                        </TabPane>
                    </Tabs>
                </div>
            </Col>
            <Col :span="span2">
                <div v-show="!this.showBox"><Tag type="dot" color="blue">{{formItem.name}} - {{formItem.medicalNumber}}</Tag><Button type="warning" @click="toggle">退出编辑</Button></div>
                <Tabs type="card" :value="selectPane" @on-click="clickTabs">
                    <TabPane name="1" label="病情描述" :disabled="disabled">
                        <complaint-details ref="compldetails" :id="complaintId"></complaint-details>
                    </TabPane>
                    <TabPane name="5" label="皮肤分类情况" :disabled="disabled">
                        <Tabs :value="selectPane5" type="card" @on-click="clickTabs5">
                            <TabPane label="皮肤分类检查" name="1">
                                <Tabs :value="selectPane6" type="card" @on-click="clickTabs6">
                                    <TabPane label="生活和护理建议" name="1">
                                        <life-care ref="lifeCare"></life-care>
                                    </TabPane>
                                    <TabPane label="皮肤分类问卷" name="5">
                                        <Button type="primary" @click="open">打开问卷管理系统</Button>
                                    </TabPane>
                                    <TabPane label="皮肤分类结果" name="4">
                                        <skin-type ref="skinType" v-on="{recommend:recommend}"></skin-type>
                                    </TabPane>
                                    <!--<TabPane label="护肤品推荐" name="2">-->
                                        <!--<Card :bordered="false" :dis-hover="true">-->
                                            <!--<p slot="title">-->
                                                <!--调查时间： 皮肤类型：-->
                                            <!--</p>-->
                                        <!--</Card>-->
                                        <!--<Tabs type="card">-->
                                            <TabPane label="产品推荐" name="3">
                                                <Card :bordered="false" :dis-hover="true">
                                                    <p slot="title" style="height: 33px">
                                                        <Button v-if="searchModal1.length === 0" type="info" @click="addCondition1">添加条件</Button>
                                                        <Button v-if="searchModal1.length !== 0" type="info" @click="search">查询</Button>
                                                        <!--<a style="font-size: 20px" v-if="searchModal1.length !== 0"> * 必须同时满足下列所有条件</a>-->
                                                    </p>
                                                    <Form :label-width="100">
                                                        <Row v-for="(item,index) in searchModal1">
                                                            <Col span="4">
                                                                <FormItem label="查询条件：">
                                                                    <Select style="width: 99%" v-model="item.field" clearable filterable transfer>
                                                                        <Option value="name">名称</Option>
                                                                        <Option value="effect">主要功效成分</Option>
                                                                        <Option value="ingredient">全成分配方</Option>
                                                                        <Option value="symptom">适用症状</Option>
                                                                        <Option value="instructions">使用方法</Option>
                                                                        <Option value="features">产品特点</Option>
                                                                        <Option value="recommend">推荐指数</Option>
                                                                    </Select>
                                                                </FormItem>
                                                            </Col>
                                                            <Col span="2">
                                                                <Select style="width: 99%" v-model="item.operate" clearable filterable transfer>
                                                                    <Option value="includ">包含</Option>
                                                                    <Option value="not includ">不包含</Option>
                                                                </Select>
                                                            </Col>
                                                            <Col span="5">
                                                                <Select v-if="item.field === 'recommend'" style="width: 99%" v-model="item.values" multiple filterable transfer>
                                                                    <Option value="O1">O1</Option>
                                                                    <Option value="O2">O2</Option>
                                                                    <Option value="O3">O3</Option>
                                                                    <Option value="D1">D1</Option>
                                                                    <Option value="D2">D2</Option>
                                                                    <Option value="D3">D3</Option>
                                                                    <Option value="S1">S1</Option>
                                                                    <Option value="S2">S2</Option>
                                                                    <Option value="S3">S3</Option>
                                                                    <Option value="R1">R1</Option>
                                                                    <Option value="R2">R2</Option>
                                                                    <Option value="R3">R3</Option>
                                                                    <Option value="P1">P1</Option>
                                                                    <Option value="P2">P2</Option>
                                                                    <Option value="P3">P3</Option>
                                                                    <Option value="N1">N1</Option>
                                                                    <Option value="N2">N2</Option>
                                                                    <Option value="N3">N3</Option>
                                                                    <Option value="W1">W1</Option>
                                                                    <Option value="W2">W2</Option>
                                                                    <Option value="W3">W3</Option>
                                                                    <Option value="T1">T1</Option>
                                                                    <Option value="T2">T2</Option>
                                                                    <Option value="T3">T3</Option>
                                                                </Select>
                                                                <Input v-if="item.field !== 'recommend'" style="width: 99%" v-model="item.value"/>
                                                            </Col>
                                                            <Col span="2">
                                                                <div style="width: 99%">
                                                                    <Button type="primary" icon="plus" @click="addCondition1"></Button>
                                                                    <Button type="error" @click="delCondition1(index)">删除</Button>
                                                                </div>
                                                            </Col>
                                                        </Row>
                                                        <Row>
                                                            <Col span="2" :offset="10">
                                                            </Col>
                                                        </Row>
                                                    </Form>
                                                </Card>
                                                <Tabs :value="selectPane7" type="card" @on-click="clickTabs7">
                                                    <TabPane label="清洁类" name="3">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="精华类" name="4">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="保湿营养类" name="5">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="防晒类" name="6">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="面膜类" name="7">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="祛斑类" name="8">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="敏感修复类" name="9">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="抗氧化抗皱纹类" name="10">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="痤疮类" name="11">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="控油/毛孔粗大产品" name="12">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane label="眼霜类" name="13">
                                                        <Table border :columns="column1" :data="data1"></Table>
                                                    </TabPane>
                                                    <TabPane :label="label1" name="14">
                                                        <Table border :columns="column2" :data="data2"></Table>
                                                    </TabPane>
                                                    <Button type="primary" @click="doAddProduct" slot="extra">保存</Button>
                                                <!--</Tabs>-->
                                            <!--</TabPane>-->
                                        </Tabs>
                                        <br>
                                        <iview-page
                                                :totalSize="pageModel.totalSize"
                                                :pageNumber="pageModel.pageNumber"
                                                :pageSize="pageModel.pageSize"
                                                :pageSizeOpts="pageModel.pageSizeOpts"
                                                v-on="{changePageNumber:changePageNumber,changePageSize:changePageSize}">
                                        </iview-page>
                                    </TabPane>
                                    <TabPane label="疗程推荐" name="2">
                                        <Card :bordered="false" :dis-hover="true">
                                            <p slot="title" style="height: 33px">
                                                <Button v-if="searchModal2.length === 0" type="info" @click="addCondition2">添加条件</Button>
                                                <Button v-if="searchModal2.length !== 0" type="info" @click="search">查询</Button>
                                                <!--<a style="font-size: 20px" v-if="searchModal1.length !== 0"> * 必须同时满足下列所有条件</a>-->
                                            </p>
                                            <Form :label-width="100">
                                                <Row v-for="(item,index) in searchModal2">
                                                    <Col span="4">
                                                        <FormItem label="查询条件：">
                                                            <Select style="width: 99%" v-model="item.field" clearable filterable transfer>
                                                                <Option value="name">名称</Option>
                                                                <Option value="recommend">推荐指数</Option>
                                                            </Select>
                                                        </FormItem>
                                                    </Col>
                                                    <Col span="2">
                                                        <Select style="width: 99%" v-model="item.operate" clearable filterable transfer>
                                                            <Option value="includ">包含</Option>
                                                            <Option value="not includ">不包含</Option>
                                                        </Select>
                                                    </Col>
                                                    <Col span="5">
                                                        <Select v-if="item.field === 'recommend'" style="width: 99%" v-model="item.values" multiple filterable transfer>
                                                            <Option value="O1">O1</Option>
                                                            <Option value="O2">O2</Option>
                                                            <Option value="O3">O3</Option>
                                                            <Option value="D1">D1</Option>
                                                            <Option value="D2">D2</Option>
                                                            <Option value="D3">D3</Option>
                                                            <Option value="S1">S1</Option>
                                                            <Option value="S2">S2</Option>
                                                            <Option value="S3">S3</Option>
                                                            <Option value="R1">R1</Option>
                                                            <Option value="R2">R2</Option>
                                                            <Option value="R3">R3</Option>
                                                            <Option value="P1">P1</Option>
                                                            <Option value="P2">P2</Option>
                                                            <Option value="P3">P3</Option>
                                                            <Option value="N1">N1</Option>
                                                            <Option value="N2">N2</Option>
                                                            <Option value="N3">N3</Option>
                                                            <Option value="W1">W1</Option>
                                                            <Option value="W2">W2</Option>
                                                            <Option value="W3">W3</Option>
                                                            <Option value="T1">T1</Option>
                                                            <Option value="T2">T2</Option>
                                                            <Option value="T3">T3</Option>
                                                        </Select>
                                                        <Input v-if="item.field !== 'recommend'" style="width: 99%" v-model="item.value"/>
                                                    </Col>
                                                    <Col span="2">
                                                        <div style="width: 99%">
                                                            <Button type="primary" icon="plus" @click="addCondition2"></Button>
                                                            <Button type="error" @click="delCondition2(index)">删除</Button>
                                                        </div>
                                                    </Col>
                                                </Row>
                                                <Row>
                                                    <Col span="2" :offset="10">
                                                    </Col>
                                                </Row>
                                            </Form>
                                        </Card>
                                        <Tabs :value="selectPane8" type="card" @on-click="clickTabs8">
                                            <TabPane label="疗程" name="1">
                                                <Table border :columns="columns3" :data="data3"></Table>
                                            </TabPane>
                                            <TabPane :label="label2" name="2">
                                                <Table border :columns="columns4" :data="data4"></Table>
                                            </TabPane>
                                            <Button type="primary" @click="doAddCourse" slot="extra">保存</Button>
                                        </Tabs>
                                        <br>
                                        <iview-page
                                                :totalSize="pageModel.totalSize"
                                                :pageNumber="pageModel.pageNumber"
                                                :pageSize="pageModel.pageSize"
                                                :pageSizeOpts="pageModel.pageSizeOpts"
                                                v-on="{changePageNumber:changePageNumber,changePageSize:changePageSize}">
                                        </iview-page>
                                    </TabPane>
                                </Tabs>
                            </TabPane>
                            <TabPane label="非创性皮肤检查" name="2">
                                <Tabs type="card" :value="selectPane2" @on-click="clickTabs2">
                                    <TabPane label="各类生理学数据" name="1">
                                        <physiological-data ref="physiologicalData"></physiological-data>
                                    </TabPane>
                                    <TabPane label="光学检查" name="2">
                                        <data-files ref="df1" :menuId="6307" :type="1"></data-files>
                                    </TabPane>
                                    <TabPane label="皮肤镜检查" name="3">
                                        <data-files ref="df2" :menuId="6308" :type="2"></data-files>
                                    </TabPane>
                                    <TabPane label="问题皮肤影像" name="4">
                                        <data-files ref="df3" :menuId="6309" :type="3"></data-files>
                                    </TabPane>
                                    <TabPane label="病理检查资料" name="5">
                                        <pathological ref="pathological"></pathological>
                                    </TabPane>
                                    <TabPane label="皮肤班帖实验" name="6">
                                        <skin-patch ref="skinPatch"></skin-patch>
                                    </TabPane>
                                    <TabPane label="最小红斑量测定" name="7">
                                        <erythema ref="erythema"></erythema>
                                    </TabPane>
                                    <TabPane label="敏感性皮肤测定" name="8">
                                        <sensitiveSkin ref="sensitiveSkin"></sensitiveSkin>
                                    </TabPane>
                                    <TabPane label="过敏源检查" name="9">
                                        <allergen ref="allergen"></allergen>
                                    </TabPane>
                                    <TabPane label="微循环检查" name="10">
                                        <microcirculation ref="microcirculation"></microcirculation>
                                    </TabPane>
                                    <TabPane label="皮肤真菌检查" name="11">
                                        <skinFungus ref="skinFungus"></skinFungus>
                                    </TabPane>
                                    <TabPane label="其他" name="12">功能即将上线...</TabPane>
                                </Tabs>
                            </TabPane>
                        </Tabs>
                    </TabPane>
                    <!--<TabPane name="12" label="护肤品推荐" :disabled="disabled">-->
                    <!--</TabPane>-->
                    <TabPane name="2" label="执行总览" :disabled="disabled">
                        <execute-list ref="executeList"></execute-list>
                    </TabPane>
                    <TabPane name="7" label="治疗方案" :disabled="disabled">
                        <treatment ref="treatment"></treatment>
                    </TabPane>
                    <TabPane name="8" label="医嘱执行" :disabled="disabled">
                        <medical-execute ref="medicalExecute"></medical-execute>
                    </TabPane>
                    <TabPane name="10" label="执行预览" :disabled="disabled">
                        <Tabs :value="selectPreview" @on-click="clickPreview">
                            <TabPane label="长期(项目)医嘱-执行记录" name="1">
                                <execute-preview ref="preview1" :type="1" :treatType="'2,3'" :itemType="1"></execute-preview>
                            </TabPane>
                            <TabPane label="长期(产品)医嘱-执行记录" name="2">
                                <execute-preview ref="preview2" :type="2" :treatType="'2,3'" :itemType="2"></execute-preview>
                            </TabPane>
                            <TabPane label="临时医嘱-执行记录" name="3">
                                <execute-preview ref="preview3" :type="3" :treatType="1" :itemType="'1,2'"></execute-preview>
                            </TabPane>
                        </Tabs>
                    </TabPane>
                    <TabPane name="9" label="病程记录" :disabled="disabled">
                        <course-record-list ref="courseRecordList"></course-record-list>
                    </TabPane>
                    <TabPane name="11" label="治疗处方单" :disabled="disabled">
                        <Tabs :value="selectDisposal" type="card" @on-click="clickDisposal">
                            <TabPane name="1" label="处置单" :disabled="disabled">
                                <project-disposal ref="projectDisposal"></project-disposal>
                            </TabPane>
                            <TabPane name="2" label="普通处方单" :disabled="disabled">
                                <Tabs :value="selectPresc" type="card" @on-click="clickPresc">
                                    <TabPane name="1" label="药品" :disabled="disabled">
                                        <drug ref="drug"></drug>
                                    </TabPane>
                                    <TabPane name="2" label="护肤品" :disabled="disabled">
                                        <disposal ref="disposal"></disposal>
                                    </TabPane>
                                    <TabPane name="3" label="填充剂" :disabled="disabled">
                                        <inject ref="inject"></inject>
                                    </TabPane>
                                </Tabs>
                            </TabPane>
                            <TabPane name="3" label="毒麻药处方单" :disabled="disabled">
                                <toxic ref="toxic"></toxic>
                            </TabPane>
                        </Tabs>
                    </TabPane>
                    <TabPane name="3" label="系统检查" :disabled="disabled">
                        <system-check-list ref="systemCheck"></system-check-list>
                    </TabPane>
                    <TabPane name="4" label="专科检查" :disabled="disabled">
                        <skin-check-list ref="skinCheck"></skin-check-list>
                    </TabPane>
                    <TabPane name="6" label="诊断及治疗建议" :disabled="disabled">
                        <Tabs type="card" :value="selectDiagnosis" @on-click="clickDiagnosis">
                            <TabPane name="1" label="皮肤病诊断">
                                <skin-diagnosis-list ref="diagnosis1" :menuId="6900" :type="1"></skin-diagnosis-list>
                            </TabPane>
                            <TabPane name="2" label="问题皮肤诊断">
                                <skin-diagnosis-list ref="diagnosis2" :menuId="6910" :type="2"></skin-diagnosis-list>
                            </TabPane>
                            <!--<TabPane name="3" label="皮肤分类">-->
                                <!--<skin-diagnosis-list :type="1"></skin-diagnosis-list>-->
                            <!--</TabPane>-->
                            <TabPane name="4" label="皮肤年轻化">
                                <skin-diagnosis-list ref="diagnosis3" :menuId="6920" :type="3"></skin-diagnosis-list>
                            </TabPane>
                        </Tabs>
                    </TabPane>
                </Tabs>
            </Col>
        </Row>
    </Card>
</template>
<script>
    import complaint from './Complaint.vue';
    import familyHistory from "./FamilyHistory.vue";
    import personalHistory from "./PersonalHistory.vue";
    import specialRecords from "./SpecialRecords.vue";
    import treatment from '@/view/business/medical/Treatment.vue';
    import complaintDetails from '@/view/business/medical/details/ComplaintDetails.vue';
    import medicalExecute from '@/view/business/medical/list/MedicalExecute.vue';
    import executeList from '@/view/business/medical/list/ExecuteList.vue';
    import executePreview from '@/view/business/medical/list/Execute.vue';
    import courseRecordList from '@/view/business/medical/list/TreatPlanCourseRecordList.vue';
    import disposal from '@/view/business/medical/list/Disposal.vue';
    import drug from '@/view/business/medical/list/Drug.vue';
    import inject from '@/view/business/medical/list/Inject.vue';
    import toxic from '@/view/business/medical/list/Toxic.vue';
    import projectDisposal from '@/view/business/medical/list/ProjectDisposal.vue';
    import skinCheckList from '@/view/business/medical/list/SkinCheckList.vue';
    import systemCheckList from '@/view/business/medical/list/SystemCheckList.vue';
    import skinDiagnosisList from '@/view/business/medical/list/SkinDiagnosisList.vue';
    import lifeCare from '@/view/business/medical/list/LifeCare.vue';
    import skinType from '@/view/business/medical/list/SkinType.vue';
    import pathological from '@/view/business/medical/list/Pathological.vue';
    import physiologicalData from '@/view/business/medical/list/PhysiologicalData.vue';
    import dataFiles from '@/view/business/medical/list/DataFiles.vue';
    import skinPatch from '@/view/business/medical/list/SkinPatch.vue';
    import erythema from '@/view/business/medical/list/Erythema.vue';
    import sensitiveSkin from '@/view/business/medical/list/SensitiveSkin.vue';
    import allergen from '@/view/business/medical/list/Allergen.vue';
    import microcirculation from '@/view/business/medical/list/Microcirculation.vue';
    import skinFungus from '@/view/business/medical/list/SkinFungus.vue';
    import Table from "../../common/table/Table";
    import iviewPage from '@/view/common/page/Page.vue';
    export default {
        components: {
            Table,
            iviewPage,
            complaint,
            familyHistory,
            personalHistory,
            specialRecords,
            treatment,
            complaintDetails,
            medicalExecute,
            executeList,
            executePreview,
            courseRecordList,
            disposal,
            drug,
            inject,
            toxic,
            projectDisposal,
            skinCheckList,
            systemCheckList,
            skinDiagnosisList,
            lifeCare,
            skinType,
            pathological,
            physiologicalData,
            dataFiles,
            skinPatch,
            erythema,
            sensitiveSkin,
            allergen,
            microcirculation,
            skinFungus
        },
        data () {
            return {
                label1: (h) => {
                    return h('div', [
                        h('span', '已选择'),
                        h('Badge', {
                            props: {
                                count: this.data2.length,
                                className: 'demo-badge'
                            }
                        })
                    ])
                },
                label2: (h) => {
                    return h('div', [
                        h('span', '已选择'),
                        h('Badge', {
                            props: {
                                count: this.data4.length,
                                className: 'demo-badge'
                            }
                        })
                    ])
                },
                span1: '10',
                span2: '14',
                showBox: true,
                patientURL: '/user/patient',
                formItem: {},
                complaintId: -1,
                selectPane: '1',
                selectPane1: '1',
                selectPane2: '1',
                selectPane5: '1',
                selectPane6: '1',
                selectPane7: '3',
                selectPane8: '1',
                selectPreview: '1',
                selectDisposal: '1',
                selectPresc: '1',
                selectDiagnosis: '1',
                disabled: true,
                selectCarousel: 0,
                baseURL: '/user/print',
                searchModal1: [],
                searchModal2: [],
                data1: [],
                column1: [
                    {
                        title: '名称',
                        key: 'name',
                        sortable: true,
                        // ellipsis: true,
                        // render: (h, params) => {
                        //     return h ('div', [
                        //         h('Poptip', {
                        //             props: {
                        //                 trigger: 'hover',
                        //                 content: params.row.name,
                        //                 placement: 'top-start'
                        //             }
                        //         },params.row.name)
                        //     ])
                        // }
                    },{
                        title: '价格',
                        key: 'price'
                    },{
                        title: '主要功效成分',
                        key: 'effect',
                        // ellipsis: true,
                        // render: (h, params) => {
                        //     return h ('div', [
                        //         h('Poptip', {
                        //             props: {
                        //                 trigger: 'hover',
                        //                 content: params.row.effect,
                        //                 placement: 'top-start'
                        //             }
                        //         },params.row.effect)
                        //     ])
                        // }
                    },{
                        title: '全成分配方',
                        key: 'ingredient',
                        // ellipsis: true,
                        // render: (h, params) => {
                        //     return h ('div', [
                        //         h('Poptip', {
                        //             props: {
                        //                 trigger: 'hover',
                        //                 content: params.row.ingredient,
                        //                 placement: 'top-start'
                        //             }
                        //         },params.row.ingredient)
                        //     ])
                        // }
                    },{
                        title: '适用症状',
                        key: 'symptom',
                        // ellipsis: true,
                        // render: (h, params) => {
                        //     return h ('div', [
                        //         h('Poptip', {
                        //             props: {
                        //                 trigger: 'hover',
                        //                 content: params.row.symptom,
                        //                 placement: 'top-start'
                        //             }
                        //         },params.row.symptom)
                        //     ])
                        // }
                    },{
                        title: '使用方法',
                        key: 'instructions',
                        // ellipsis: true,
                        // render: (h, params) => {
                        //     return h ('div', [
                        //         h('Poptip', {
                        //             props: {
                        //                 trigger: 'hover',
                        //                 content: params.row.instructions,
                        //                 placement: 'top-start'
                        //             }
                        //         },params.row.instructions)
                        //     ])
                        // }
                    },{
                        title: '产品特点',
                        key: 'features',
                        // ellipsis: true,
                        // render: (h, params) => {
                        //     return h ('div', [
                        //         h('Poptip', {
                        //             props: {
                        //                 trigger: 'hover',
                        //                 content: params.row.features,
                        //                 placement: 'top-start'
                        //             }
                        //         },params.row.features)
                        //     ])
                        // }
                    },{
                        title: '推荐指数',
                        key: 'recommend',
                    },
                    // {
                    //     title: '大类',
                    //     key: 'bigClassName',
                    // },{
                    //     title: '小类',
                    //     key: 'smallClassName',
                    // },
                    {
                        title: '操作',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'info',
                                        size: 'default'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.addProduct(params.row)
                                        }
                                    }
                                }, '选择')
                            ]);
                        }
                    }
                ],
                data2: [],
                column2: [
                    {
                        title: '名称',
                        key: 'name',
                    },{
                        title: '大类',
                        key: 'bigClassName',
                    },{
                        title: '小类',
                        key: 'smallClassName',
                    },{
                        title: '单价',
                        key: 'price',
                    },
                    {
                        title: '数量',
                        key: 'quantity',
                        render: (h, params) => {
                            var vm = this
                            return h('InputNumber',{
                                props: {
                                    min: 1,
                                    value: params.row.quantity
                                },
                                style: {
                                    width: '100%'
                                },
                                on: {
                                    'on-change' (value) {
                                        params.row.quantity = value
                                        vm.data2[params.index] = params.row
                                    }
                                }
                            });
                        }
                    },
                    {
                        title: '操作',
                        width: 200,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'default'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.deleteProduct(params.index)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
                ],
                data3: [],
                columns3: [
                    {
                        title: '名称',
                        key: 'name',
                    },
                    {
                        title: '原价格',
                        key: 'originalPrice',
                    },
                    {
                        title: '优惠后价格',
                        key: 'price',
                    },
                    {
                        title: '推荐指数',
                        key: 'recommend',
                    },{
                        title: '操作',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'info',
                                        size: 'default'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.addCourse(params.row)
                                        }
                                    }
                                }, '选择')
                            ]);
                        }
                    }
                ],
                data4: [],
                columns4: [
                    {
                        title: '名称',
                        key: 'name',
                    },
                    {
                        title: '单价',
                        key: 'price',
                    },
                    {
                        title: '数量',
                        key: 'quantity',
                        render: (h, params) => {
                            var vm = this
                            return h('InputNumber',{
                                props: {
                                    min: 1,
                                    value: params.row.quantity
                                },
                                style: {
                                    width: '100%'
                                },
                                on: {
                                    'on-change' (value) {
                                        params.row.quantity = value
                                        vm.data2[params.index] = params.row
                                    }
                                }
                            });
                        }
                    },
                    {
                        title: '操作',
                        width: 200,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'error',
                                        size: 'default'
                                    },
                                    style: {
                                        marginRight: '5px'
                                    },
                                    on: {
                                        click: () => {
                                            this.deleteCourse(params.index)
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
                ],
                pageModel: {
                    totalSize: 0,
                    pageNumber: 1,
                    pageSize: 10,
                    pageSizeOpts: [10, 50, 100, 500]
                }
            }
        },
        filters: {
            valueFilter (value) {
                let temp = value
                if (temp === undefined || temp === '') {
                    temp = '未填写'
                }
                return temp
            },
            sexFilter (value) {
                let temp = '未填写'
                if (value === 1) {
                    temp = '男'
                } else if (value === 2) {
                    temp = '女'
                } else {
                    temp = '无'
                }
                return temp
            },
            ethnicFilter (value) {
                let temp = '未填写'
                if (value === 0) {
                    temp = '汉族'
                } else if (value === 1) {
                    temp = '非汉族'
                } else if (value === 2) {
                    temp = '其他'
                }
                return temp;
            },
            maritalFilter (value) {
                let temp = '未填写'
                if (value === 0) {
                    temp = '未婚'
                } else if (value === 1) {
                    temp = '已婚'
                }
                return temp;
            },
            cultureFilter (value) {
                let temp = '未填写'
                if (value === 0) {
                    temp = '小学'
                } else if (value === 1) {
                    temp = '初中'
                } else if (value === 2) {
                    temp = '高中'
                } else if (value === 3) {
                    temp = '大学'
                } else if (value === 4) {
                    temp = '研究生'
                } else if (value === 5) {
                    temp = '博士生'
                }
                return temp;
            },
            jobFilter (value) {
                let temp = '未填写'
                if (value === 0) {
                    temp = '公司职员'
                } else if (value === 1) {
                    temp = '运动员'
                } else if (value === 2) {
                    temp = '演艺业'
                } else if (value === 3) {
                    temp = '学生'
                } else if (value === 4) {
                    temp = '记者'
                } else if (value === 5) {
                    temp = '公务员'
                } else if (value === 6) {
                    temp = '其他'
                }
                return temp;
            },
            jobCharactFilter (value) {
                let temp = '未填写'
                if (value === 0) {
                    temp = '户外为主'
                } else if (value === 1) {
                    temp = '户内为主'
                } else if (value === 2) {
                    temp = '户外户内工作时间没有区别'
                }
                return temp;
            },
            sourceFilter (value) {
                let temp = '未填写'
                if (value === 0) {
                    temp = '官方微信'
                } else if (value === 1) {
                    temp = '官方微博'
                } else if (value === 2) {
                    temp = '个人微信'
                } else if (value === 3) {
                    temp = '个人微博'
                } else if (value === 4) {
                    temp = '官方网站'
                } else if (value === 5) {
                    temp = '官方APP'
                } else if (value === 6) {
                    temp = '报纸'
                } else if (value === 7) {
                    temp = '电视'
                } else if (value === 8) {
                    temp = '电台'
                } else if (value === 9) {
                    temp = '朋友介绍'
                } else if (value === 10) {
                    temp = '家人推荐'
                } else if (value === 11) {
                    temp = '框架广告'
                }
                return temp;
            }
        },
        methods: {
            open () {
                let url = 'http://47.100.124.176:8082'
                window.open(url)
            },
            recommend (row) {
                let values = []
                let temp = ''
                if (row.type1 === 1) {
                    temp = 'O' + row.sub1
                } else if (row.type1 === 2) {
                    temp = 'D' + row.sub1
                }
                values.push(temp)
                if (row.type2 === 1) {
                    temp = 'S' + row.sub2
                } else if (row.type2 === 2) {
                    temp = 'R' + row.sub2
                }
                values.push(temp)
                if (row.type3 === 1) {
                    temp = 'P' + row.sub3
                } else if (row.type3 === 2) {
                    temp = 'N' + row.sub3
                }
                values.push(temp)
                if (row.type4 === 1) {
                    temp = 'W' + row.sub4
                } else if (row.type4 === 2) {
                    temp = 'T' + row.sub4
                }
                values.push(temp)
                this.searchModal1 = []
                this.searchModal2 = []
                this.searchModal1.push({
                    field: 'recommend',
                    operate: 'includ',
                    value: '',
                    values: values
                })
                this.searchModal2.push({
                    field: 'recommend',
                    operate: 'includ',
                    value: '',
                    values: values
                })
                this.selectPane6 = '3'
            },
            doAddProduct () {
                if (this.data2.length > 0) {
                    let url = '/user/treat/plan/product/saveOrUpdate/' + this.$store.state.app.patientId
                    this.$ajax.post(url, this.data2).then((response) => {
                        let {code, msg} = response.data
                        if (code === 0) {
                            this.$bus.alert('success', '已保存')
                            this.data2 = []
                        } else {
                            this.$bus.alert('error', msg)
                        }
                    })
                } else {
                    this.$bus.alert('warning', '你没有添加任何产品')
                }
            },
            doAddCourse () {
                if (this.data4.length > 0) {
                    let url = '/user/treat/plan/course/saveOrUpdate/' + this.$store.state.app.patientId
                    this.$ajax.post(url, this.data4).then((response) => {
                        let {code, msg} = response.data
                        if (code === 0) {
                            this.$bus.alert('success', '已保存')
                            this.data4 = []
                        } else {
                            this.$bus.alert('error', msg)
                        }
                    })
                } else {
                    this.$bus.alert('warning', '你没有添加任何疗程')
                }
            },
            addProduct (row) {
                // 标识添加的数据是产品
                row.complaintId = this.$store.state.app.complaintId
                row.productId = row.id
                row.productName = row.name
                row.price = row.price
                row.quantity = 1
                this.data2.push(row)
            },
            addCourse (row) {
                // 标识添加的数据是产品
                row.complaintId = this.$store.state.app.complaintId
                row.courseId = row.id
                row.courseName = row.name
                row.price = row.price
                row.quantity = 1
                this.data4.push(row)
            },
            deleteProduct (index) {
                this.data2.splice(index, 1)
            },
            deleteCourse (index) {
                this.data4.splice(index, 1)
            },
            addCondition1 () {
                this.searchModal1.push({
                    field: '',
                    operate: '',
                    value: '',
                    values: []
                })
            },
            addCondition2 () {
                this.searchModal2.push({
                    field: '',
                    operate: '',
                    value: '',
                    values: []
                })
            },
            delCondition1 (index) {
                this.searchModal1.splice(index, 1)
            },
            delCondition2 (index) {
                this.searchModal2.splice(index, 1)
            },
            search () {
                if (this.selectPane6 === '2') {
                    let url = '/user/course/searchByModel/' + this.pageModel.pageNumber + '/' + this.pageModel.pageSize
                    this.$ajax.post(url, this.searchModal2).then(r => {
                        let {code, data, params, msg} = r.data
                        if (code === 0) {
                            this.data3 = data
                            this.pageModel.pageNumber = params.pageNumber
                            this.pageModel.pageSize = params.pageSize
                            this.pageModel.totalSize = params.totalSize
                        } else {
                            this.$bus.alert('error', msg)
                        }
                    })
                } else if (this.selectPane6 === '3') {
                    let url = '/user/product/searchByModel/' + this.selectPane7 + '/' + this.pageModel.pageNumber + '/' + this.pageModel.pageSize
                    this.$ajax.post(url, this.searchModal1).then(r => {
                        let {code, data, params, msg} = r.data
                        if (code === 0) {
                            this.data1 = data
                            this.pageModel.pageNumber = params.pageNumber
                            this.pageModel.pageSize = params.pageSize
                            this.pageModel.totalSize = params.totalSize
                        } else {
                            this.$bus.alert('error', msg)
                        }
                    })
                }
            },
            init () {
                let url = this.patientURL + '/findById/' + this.$store.state.app.patientId
                this.$ajax.get(url).then((response) => {
                    let {code, data, msg} = response.data
                    if (code === 0) {
                        this.formItem = data
                    } else {
                        this.$bus.alert('error', msg)
                    }
                })
            },
            toggle () {
                this.showBox = !this.showBox
                if (this.showBox) {
                    this.$store.state.app.complaintId = ''
                }
            },
            selectComplaint (id) {
                this.complaintId = id
                this.$store.state.app.complaintId = id
                this.$refs.compldetails.refresh()
                this.toggle()
            },
            clickTabs (name) {
                // 选择治疗方案时
                if (name === '2') {
                    this.$refs.executeList.refresh()
                } else if (name === '6') {
                    this.selectDiagnosis = '1'
                    this.$refs.diagnosis1.refresh()
                } else if (name === '7') {
                    this.$refs.treatment.refreshProjectList()
                } else if (name === '8') {
                    this.$refs.medicalExecute.refreshList1()
                } else if (name === '9') {
                    this.$refs.courseRecordList.refresh()
                } else if (name === '10') {
                    this.$refs.preview1.refresh()
                    this.selectPreview = '1'
                } else if (name === '11') {
                    this.selectDisposal = '1'
                    this.$refs.projectDisposal.search()
                } else if (name === '3') {
                    this.$refs.systemCheck.refresh()
                } else if (name === '4') {
                    this.$refs.skinCheck.refresh()
                } else if (name === '5') {
                    this.$refs.lifeCare.refresh()
                    this.selectPane5 = '1'
                }
                this.selectPane = name
            },
            clickTabs1 (name) {
                if (name === '1') {
                    this.$refs.complaint1.refresh()
                } else if (name === '2') {
                    this.$refs.complaint2.refresh()
                } else if (name === '3') {
                    this.$refs.familyHistory.search()
                } else if (name === '4') {
                    this.$refs.personalHistory.search()
                }
                this.selectPane1 = name
            },
            clickTabs2 (name) {
                if (name === '1') {
                    this.$refs.physiologicalData.refresh()
                } else if (name === '2') {
                    this.$refs.df1.refresh()
                } else if (name === '3') {
                    this.$refs.df2.refresh()
                } else if (name === '4') {
                    this.$refs.df3.refresh()
                } else if (name === '5') {
                    this.$refs.pathological.refresh()
                } else if (name === '6') {
                    this.$refs.skinPatch.refresh()
                } else if (name === '7') {
                    this.$refs.erythema.refresh()
                } else if (name === '8') {
                    this.$refs.sensitiveSkin.refresh()
                } else if (name === '9') {
                    this.$refs.allergen.refresh()
                } else if (name === '10') {
                    this.$refs.microcirculation.refresh()
                } else if (name === '11') {
                    this.$refs.skinFungus.refresh()
                }
                this.selectPane2 = name
            },
            clickTabs5 (name) {
                if (name === '1') {
                    this.$refs.lifeCare.refresh()
                } else if (name === '2') {
                    this.clickTabs2('1')
                }
                this.selectPane5 = name
            },
            clickTabs6 (name) {
                if (name === '1') {

                } else if (name === '2') {
                    this.selectPane8 = '1'
                } else if (name === '3') {
                    this.selectPane7 = '3'
                } else if (name === '4') {
                    this.$refs.skinType.refresh()
                }
                this.selectPane6 = name
            },
            clickTabs7 (name) {
                this.selectPane7 = name
                if (name !== '14') {
                    this.pageModel.pageNumber = 1
                    this.search()
                }
            },
            clickTabs8 (name) {
                if (name === '1') {
                    this.search()
                }
                this.selectPane8 = name
            },
            clickPreview (name) {
                if (name === '1') {
                    this.$refs.preview1.refresh()
                } else if (name === '2') {
                    this.$refs.preview2.refresh()
                } else if (name === '3') {
                    this.$refs.preview3.refresh()
                }
                this.selectPreview = name
            },
            clickDisposal (name) {
                if (name === '1') {
                    this.$refs.projectDisposal.search()
                } else if (name === '2') {
                    this.$refs.drug.search()
                } else if (name === '3') {
                    this.$refs.toxic.search()
                }
                this.selectDisposal = name
            },
            clickPresc (name) {
                if (name === '1') {
                    this.$refs.drug.search()
                } else if (name === '2') {
                    this.$refs.disposal.search()
                } else if (name === '3') {
                    this.$refs.inject.search()
                }
                this.selectPresc = name
            },
            clickDiagnosis (name) {
                if (name === '1') {
                    this.$refs.diagnosis1.refresh()
                } else if (name === '2') {
                    this.$refs.diagnosis2.refresh()
                } else if (name === '3') {
                    this.$bus.modal('info', '系统提示', '功能建设中...')
                } else if (name === '4') {
                    this.$refs.diagnosis3.refresh()
                }
                this.selectDiagnosis = name
            },
            printMedical () {
                let url = this.$store.state.app.WEBROOT + '/user/print/medical?patientId=' + this.$route.query.id + '&userId=' + this.$store.state.app.loginUser.id
                window.open(url)
            },
            printExecute () {
                let url = this.$store.state.app.WEBROOT + '/user/print/allAdviceExecute?patientId=' + this.$route.query.id + '&userId=' + this.$store.state.app.loginUser.id
                window.open(url)
            },
            printCourse () {
                let url = this.$store.state.app.WEBROOT + '/user/print/courseRecords?patientId=' + this.$route.query.id + '&userId=' + this.$store.state.app.loginUser.id
                window.open(url)
            },
            exit () {
                this.$store.state.app.close = true
                this.selectPane = '1'
                this.disabled = true
                this.$store.state.app.patientId = ''
                this.$store.state.app.complaintId = ''
                this.$bus.closePageToLink()
            },
            changeTotalSize (totalSize) {
                this.pageModel.totalSize = totalSize
            },
            changePageNumber (pageNumber) {
                this.pageModel.pageNumber = pageNumber
                this.search()
            },
            changePageSize (pageSize) {
                this.pageModel.pageSize = pageSize
                this.search()
            }
        },
        created () {
            this.init()
        },
        mounted () {
            // this.init()
        },
        updated () {
            this.$store.state.app.percent = 100
        },
        activated () {
        },
        beforeRouteEnter (to, from, next) {
            next(vm => {

            })
        },
        beforeRouteLeave (to, from, next) {
            // this.$bus.alert('info', this.$store.state.app.close)
            if (!this.$store.state.app.close) {
                this.$Modal.confirm({
                    title: '操作提示',
                    content: '<p>系统检测到你即将离开当前页面，请确认你的病案资料是否全部保存，如果已经保存，请点击确认离开</p>',
                    onOk: () => {
                        this.selectPane = '1'
                        this.disabled = true
                        this.$store.state.app.patientId = ''
                        this.$store.state.app.complaintId = ''
                        this.$store.state.app.close = true
                        this.$bus.closePageToLink()
                    }
                })
            } else {
                this.selectPane = '1'
                this.disabled = true
                this.$store.state.app.patientId = ''
                this.$store.state.app.complaintId = ''
                next()
            }
        },
        watch: {
            '$store.state.app.complaintId': function (val, oldVal) {
                if (val !== '') {
                    this.disabled = false
                } else {
                    this.selectPane = '1'
                    this.disabled = true
                }
            },
            showBox: function (val, oldVal) {
                if (val) {
                    this.span1 = '10'
                    this.span2 = '14'
                } else {
                    this.span1 = '0'
                    this.span2 = '24'
                }
            }
        }
    }
</script>
<style>
    .code-row-col-name{
        text-align: right;
        border: 1px solid #F7FBFF;
        background-color: #EDF3F4;
    }
    .code-row-col-value{
        padding-left: 10px;
        border: 1px solid #D5E4F1;
    }
    .top,.bottom{
        text-align: center;
    }
    .center{
        width: 100%;
        margin: 10px auto;
        overflow: hidden;
    }
    .center-left{
        float: left;
    }
    .center-right{
        float: right;
    }
</style>